<template>

   <div>
       账号:
       <input type="text" v-model="name">
       <input type="button" value="登录" @click="dl">
   </div>

</template>

<script>
import Axios from 'axios'
export default {
   data(){
       return {
           name:'',
           pas:''
       }
   },
   methods:{
       dl(){
           let fd=new FormData()
           fd.append('username',this.name)
           Axios.post('http://127.0.0.1:8000/login/login',fd).then(resp=>{
               console.log(resp)
               if (resp.data.code==200){
                   alert(resp.data.msg)
                   sessionStorage.setItem('token',resp.data.token)
                   sessionStorage.setItem('username',this.name)
                   this.$router.push('tushu2')
               }else{
                   alert(resp.data.msg)
               }
           })
       }
   }
}
</script>

<style>

</style>